package com.premierleaguestats.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class PremierLeagueStats implements EntryPoint {
	
	//private TabPanel tabPanel = new TabPanel();
	private MenuBar menuBar = new MenuBar();
	public static VerticalPanel mainPanel = new VerticalPanel();
	
	/**
	 * This is the entry point method.
	 */

	public void onModuleLoad() {
		
		String initToken = History.getToken();
		
		if(initToken.length() == 0){
			History.newItem("teamstats");
		}
		
		Command teamStatsCmd = new Command() {
			@Override
			public void execute() {
				History.newItem("teamstats");
				System.out.println("Team Stats");
			}
		};
		
		Command winnerStatsCmd = new Command (){
			@Override
			public void execute() {
				History.newItem("winnerstats");
				System.out.println("Winner Stats");
			}
		};
		
		History.addValueChangeHandler(new MyHistoryListener());
		History.fireCurrentHistoryState();
		
		MenuItem teamStats = new MenuItem("Team Stats", teamStatsCmd);
		MenuItem winnerStats = new MenuItem("Winner stats", winnerStatsCmd);
		
		// Setting up tabs
		menuBar.addItem(teamStats);
		menuBar.addItem(winnerStats);
		
		mainPanel.add(menuBar);
		
		System.out.println(menuBar.getItemIndex(teamStats));
		
		RootPanel.get("panel").add(menuBar);
		
	}
	
}